console.log('EUV')
function observe(obj) {
    for (const key in obj) {
        let internalValue = obj[key]
        let funcs = []
        Object.defineProperty(obj, key, {
            get: function () {
                // 依赖搜集
                const cb = window.__func
                if (cb && !funcs.includes(cb)) {
                    funcs.push(cb)
                }
                return internalValue
            },
            set: function (val) {
                internalValue = val
                // 派发更新
                funcs.forEach(item => item())
            }
        })
    }
}

function autorun(fn) {
    window.__func = fn
    fn()
    window.__func = null
}